<?php

$matches = array();

if ( preg_match('#^/(\d{4})(?:/(\d{2})(?:/(\d{2})(?:/(.+))))$#', $_SERVER['PATH_INFO'], &$matches) )
{
  $num_matches = count($matches);

  if ($num_matches == 2)
    define('PRESSLESS_ACTION', 'year');
  elseif ($num_matches == 3)
    define('PRESSLESS_ACTION', 'month');
  elseif ($num_matches == 4)
    define('PRESSLESS_ACTION', 'day');
  elseif ($num_matches == 5)
    define('PRESSLESS_ACTION', 'post');

  switch ($num_matches)
  {
  case 5:
    $_GET['slug']  = $matches[4];
  case 4:
    $_GET['day'] = $matches[3];
  case 3:
    $_GET['month'] = $matches[2];
  case 2:
    $_GET['year'] = $matches[1];
  }

  return;
}

if ( preg_match('#^/tag/(.+)$#', $_SERVER['PATH_INFO'], &$matches) )
{
  define('PRESSLESS_ACTION', 'tag');

  $_GET['tag'] = $matches[1];

  return;
}

?>
